package com.hjm.project.profitSummary.profitSummary.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.profitSummary.profitSummary.domain.ProfitSummary;
import com.hjm.project.profitSummary.profitSummary.service.IProfitSummaryService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 日分润汇总Controller
 * 
 * @author LOVE
 * @date 2020-11-27
 */
@Controller
@RequestMapping("/profitSummary/profitSummary")
public class ProfitSummaryController extends BaseController
{
    private String prefix = "profitSummary/profitSummary";

    @Autowired
    private IProfitSummaryService profitSummaryService;

    @RequiresPermissions("profitSummary:profitSummary:view")
    @GetMapping()
    public String profitSummary()
    {
        return prefix + "/profitSummary";
    }

    /**
     * 查询日分润汇总列表
     */
    @RequiresPermissions("profitSummary:profitSummary:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProfitSummary profitSummary)
    {
        startPage();
        List<ProfitSummary> list = profitSummaryService.selectProfitSummaryList(profitSummary);
        return getDataTable(list);
    }

    /**
     * 导出日分润汇总列表
     */
    @RequiresPermissions("profitSummary:profitSummary:export")
    @Log(title = "日分润汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ProfitSummary profitSummary)
    {
        List<ProfitSummary> list = profitSummaryService.selectProfitSummaryList(profitSummary);
        ExcelUtil<ProfitSummary> util = new ExcelUtil<ProfitSummary>(ProfitSummary.class);
        return util.exportExcel(list, "profitSummary");
    }

    /**
     * 新增日分润汇总
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存日分润汇总
     */
    @RequiresPermissions("profitSummary:profitSummary:add")
    @Log(title = "日分润汇总", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ProfitSummary profitSummary)
    {
        return toAjax(profitSummaryService.insertProfitSummary(profitSummary));
    }

    /**
     * 修改日分润汇总
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ProfitSummary profitSummary = profitSummaryService.selectProfitSummaryById(id);
        mmap.put("profitSummary", profitSummary);
        return prefix + "/edit";
    }

    /**
     * 修改保存日分润汇总
     */
    @RequiresPermissions("profitSummary:profitSummary:edit")
    @Log(title = "日分润汇总", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ProfitSummary profitSummary)
    {
        return toAjax(profitSummaryService.updateProfitSummary(profitSummary));
    }

    /**
     * 删除日分润汇总
     */
    @RequiresPermissions("profitSummary:profitSummary:remove")
    @Log(title = "日分润汇总", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(profitSummaryService.deleteProfitSummaryByIds(ids));
    }
}
